import socket
import time

def main():
    tcp_server_socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
    tcp_server_socket.bind(('127.0.0.1',7890))
    tcp_server_socket.listen()
    # 返回一个元组
    new_client_socket,client_addr = tcp_server_socket.accept()
    print(client_addr)
    # 接收客户端发送过来的请求
    i = 0
    tmp1 = time.time()
    datas = [b"\x05\x0A\x0F\x0D\x11\x12\x13\x14",b"\x0D\x0F\x0A\x05\x11\x12\x13\x14",b"\x0A\x05\x0D\x0F\x11\x12\x13\x14"]
    while(i < 50000) :
        recv_data = new_client_socket.recv(1024)
        #print(recv_data)
        # 返回给客户端数据
        new_client_socket.send(datas[i % 3])
        i = i + 1
        #print(i)
    tmp2 = time.time()
    print(tmp2-tmp1)
    new_client_socket.close()
    tcp_server_socket.close()

if __name__ == '__main__':
    main()
    